package com.punai.monthanalysis.bo;

import cn.hutool.core.collection.CollUtil;
import com.punai.monthanalysis.domain.ProYdcbfxDwgccsffxb;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class ProYdcbfxDwgccsffxbBo extends ProYdcbfxDwgccsffxb {
    private Integer rowspan = 1;
    private Integer colspan = 1;
    private String name;//分项名称
    private List<ProYdcbfxDwgccsffxbBo> children = new ArrayList<>();

    public void clearColRow() {
        this.setRowspan(0);
        this.setColspan(0);
    }

    public static List<ProYdcbfxDwgccsffxbBo> convert(Map<String, List<ProYdcbfxDwgccsffxbBo>> listMap) {
        List<ProYdcbfxDwgccsffxbBo> result = new ArrayList<>();
        if (CollUtil.isEmpty(listMap)) {
            return result;
        }
        for (Map.Entry<String, List<ProYdcbfxDwgccsffxbBo>> listEntry : listMap.entrySet()) {
            List<ProYdcbfxDwgccsffxbBo> entryValues = listEntry.getValue();
            for (int i = 0; i < entryValues.size(); i++) {
                ProYdcbfxDwgccsffxbBo bo = entryValues.get(i);
                if (i == 0){
                    bo.setRowspan(entryValues.size());
                }else {
                    bo.setItemName(null);
                    bo.clearColRow();
                }
                result.add(bo);
            }
        }
        return result;
    }

    public Integer getRowspan() {
        return rowspan;
    }

    public void setRowspan(Integer rowspan) {
        this.rowspan = rowspan;
    }

    public Integer getColspan() {
        return colspan;
    }

    public void setColspan(Integer colspan) {
        this.colspan = colspan;
    }

    public List<ProYdcbfxDwgccsffxbBo> getChildren() {
        return children;
    }

    public void setChildren(List<ProYdcbfxDwgccsffxbBo> children) {
        this.children = children;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
